Conversation
manage encoding error
for more information, see https://pre-commit.ci
|
I'm not sure this improves things and it changes an unrelated thing at the same time. |
|
But at least it indicates you which file needs to be checked. What would you suggest instead? I am open to any other solutions. |
I think changing
I would flip this around. I sympathize that your coworker got stuck, but given that CI was green before your coworker's change, and CI was red with something in the change, then it's reasonable for your coworker to try testing each file in the changelist one-by-one to see which file caused the issue. |
I noticed that official
check_yamlhook throws aUnicodeDecodeErrorin case of invalid file encoding without providing any details about the invalid yaml file. This makes it very difficult for the developer to figure out which file is causing the problem.Example of error stack-trace:
This PR improves the reliability of the
check_yamlhook by ensuring it handles also YAML containing characters that violates file encoding.In case of
UnicodeDecodeErrorthe hook notify the error and prints a simple message to indicate the file path that generate the error.The same behaviour applies also in case of
ruamel.yaml.YAMLError(obviously with a different error message).I made also a new unit test to complete the test coverage over my new changes.
Please, take a look on my little changes.
I hope this has been helpful and I look forward to hearing your feedback.